VERSION 5.00
Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "mscomctl.ocx"
Object = "{BDC217C8-ED16-11CD-956C-0000C04E4C0A}#1.1#0"; "TABCTL32.OCX"
Object = "{CDE57A40-8B86-11D0-B3C6-00A0C90AEA82}#1.0#0"; "MSDATGRD.OCX"
Object = "{B3FB64BF-91F9-11D7-A482-0008A14158BC}#2.11#0"; "ITGControls.ocx"
Begin VB.Form frmSupplyBorrow 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "Supplies Borrowers Slip"
   ClientHeight    =   5715
   ClientLeft      =   15
   ClientTop       =   240
   ClientWidth     =   8100
   BeginProperty Font 
      Name            =   "Tahoma"
      Size            =   8.25
      Charset         =   0
      Weight          =   400
      Underline       =   0   'False
      Italic          =   0   'False
      Strikethrough   =   0   'False
   EndProperty
   Icon            =   "frmSupplyBorrow.frx":0000
   KeyPreview      =   -1  'True
   LinkTopic       =   "Form1"
   LockControls    =   -1  'True
   MaxButton       =   0   'False
   MDIChild        =   -1  'True
   ScaleHeight     =   5715
   ScaleWidth      =   8100
   Begin TabDlg.SSTab SSTab1 
      Height          =   5340
      Left            =   60
      TabIndex        =   7
      Top             =   60
      Width           =   7980
      _ExtentX        =   14076
      _ExtentY        =   9419
      _Version        =   393216
      Tabs            =   2
      TabsPerRow      =   2
      TabHeight       =   520
      TabMaxWidth     =   3528
      TabCaption(0)   =   "Main"
      TabPicture(0)   =   "frmSupplyBorrow.frx":0CCA
      Tab(0).ControlEnabled=   -1  'True
      Tab(0).Control(0)=   "Frame1"
      Tab(0).Control(0).Enabled=   0   'False
      Tab(0).ControlCount=   1
      TabCaption(1)   =   "List"
      TabPicture(1)   =   "frmSupplyBorrow.frx":0CE6
      Tab(1).ControlEnabled=   0   'False
      Tab(1).Control(0)=   "dtgList"
      Tab(1).ControlCount=   1
      Begin VB.Frame Frame1 
         Height          =   4860
         Left            =   120
         TabIndex        =   8
         Top             =   360
         Width           =   7725
         Begin VB.CommandButton cmdPickCode 
            Height          =   300
            Left            =   2700
            Picture         =   "frmSupplyBorrow.frx":0D02
            Style           =   1  'Graphical
            TabIndex        =   3
            Top             =   1065
            Width           =   315
         End
         Begin VB.Timer Timer1 
            Interval        =   300
            Left            =   2700
            Top             =   240
         End
         Begin ITGControls.ITGTextBox txtTranNo 
            Height          =   285
            Left            =   240
            TabIndex        =   0
            Top             =   240
            Width           =   2445
            _ExtentX        =   4313
            _ExtentY        =   503
            SendKeysTab     =   -1  'True
            BackColor       =   14745599
            BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            AllCaps         =   -1  'True
            Mandatory       =   -1  'True
            Label           =   "SBS No."
            BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            LabelWidth      =   1250
            TextBoxWidth    =   1195
            Required        =   -1  'True
         End
         Begin ITGControls.ITGDateBox dtbDate 
            Height          =   285
            Left            =   5895
            TabIndex        =   1
            Tag             =   "Transaction Date"
            Top             =   240
            Width           =   1305
            _ExtentX        =   2302
            _ExtentY        =   503
            BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Text            =   ""
            SendKeysTab     =   -1  'True
            Mandatory       =   -1  'True
         End
         Begin ITGControls.ITGLabel ITGLabel4 
            Height          =   285
            Left            =   5325
            TabIndex        =   9
            Top             =   240
            Width           =   525
            _ExtentX        =   926
            _ExtentY        =   503
            Caption         =   "Date"
            BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
         End
         Begin ITGControls.ITGTextBox txtCustDesc 
            Height          =   285
            Left            =   3060
            TabIndex        =   14
            TabStop         =   0   'False
            Top             =   1065
            Width           =   4095
            _ExtentX        =   7223
            _ExtentY        =   503
            SendKeysTab     =   -1  'True
            BackColor       =   14737632
            BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            AllCaps         =   -1  'True
            Label           =   "ITGtext"
            BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            LabelWidth      =   0
            TextBoxWidth    =   4095
            Enabled         =   0   'False
         End
         Begin ITGControls.ITGTextBox txtCode 
            Height          =   285
            Left            =   225
            TabIndex        =   2
            Top             =   1065
            Width           =   2430
            _ExtentX        =   4286
            _ExtentY        =   503
            SendKeysTab     =   -1  'True
            BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            AllCaps         =   -1  'True
            Mandatory       =   -1  'True
            Label           =   "Customer"
            BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            LabelWidth      =   1250
            TextBoxWidth    =   1180
            Required        =   -1  'True
         End
         Begin ITGControls.ITGTextBox txtAttention 
            Height          =   285
            Left            =   225
            TabIndex        =   4
            Top             =   1425
            Width           =   6930
            _ExtentX        =   12224
            _ExtentY        =   503
            SendKeysTab     =   -1  'True
            BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            AllCaps         =   -1  'True
            Label           =   "Attention"
            BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            LabelWidth      =   1250
            TextBoxWidth    =   5680
         End
         Begin MSDataGridLib.DataGrid dtgSBS 
            Height          =   1905
            Left            =   240
            TabIndex        =   6
            Top             =   2700
            Width           =   7215
            _ExtentX        =   12726
            _ExtentY        =   3360
            _Version        =   393216
            AllowUpdate     =   -1  'True
            AllowArrows     =   -1  'True
            BackColor       =   16777215
            HeadLines       =   1
            RowHeight       =   15
            TabAcrossSplits =   -1  'True
            TabAction       =   2
            FormatLocked    =   -1  'True
            AllowDelete     =   -1  'True
            BeginProperty HeadFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            ColumnCount     =   4
            BeginProperty Column00 
               DataField       =   "cItemNo"
               Caption         =   "Product ID"
               BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
                  Type            =   0
                  Format          =   "0.00"
                  HaveTrueFalseNull=   0
                  FirstDayOfWeek  =   0
                  FirstWeekOfYear =   0
                  LCID            =   1033
                  SubFormatType   =   0
               EndProperty
            EndProperty
            BeginProperty Column01 
               DataField       =   "cDesc"
               Caption         =   "Description"
               BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
                  Type            =   0
                  Format          =   ""
                  HaveTrueFalseNull=   0
                  FirstDayOfWeek  =   0
                  FirstWeekOfYear =   0
                  LCID            =   1033
                  SubFormatType   =   0
               EndProperty
            EndProperty
            BeginProperty Column02 
               DataField       =   "cUnit"
               Caption         =   "Unit"
               BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
                  Type            =   0
                  Format          =   ""
                  HaveTrueFalseNull=   0
                  FirstDayOfWeek  =   0
                  FirstWeekOfYear =   0
                  LCID            =   1033
                  SubFormatType   =   0
               EndProperty
            EndProperty
            BeginProperty Column03 
               DataField       =   "nQty"
               Caption         =   "Quantity"
               BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
                  Type            =   1
                  Format          =   "#,##0.00"
                  HaveTrueFalseNull=   0
                  FirstDayOfWeek  =   0
                  FirstWeekOfYear =   0
                  LCID            =   1033
                  SubFormatType   =   1
               EndProperty
            EndProperty
            SplitCount      =   1
            BeginProperty Split0 
               BeginProperty Column00 
                  Button          =   -1  'True
                  ColumnWidth     =   1305.071
               EndProperty
               BeginProperty Column01 
                  Locked          =   -1  'True
                  ColumnWidth     =   3119.811
               EndProperty
               BeginProperty Column02 
                  Locked          =   -1  'True
                  ColumnWidth     =   915.024
               EndProperty
               BeginProperty Column03 
                  Alignment       =   1
                  ColumnWidth     =   1319.811
               EndProperty
            EndProperty
         End
         Begin ITGControls.ITGTextBox txtRemarks 
            Height          =   285
            Left            =   225
            TabIndex        =   5
            Top             =   1800
            Width           =   6930
            _ExtentX        =   12224
            _ExtentY        =   503
            SendKeysTab     =   -1  'True
            BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            AllCaps         =   -1  'True
            Label           =   "Remarks"
            BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            LabelWidth      =   1250
            TextBoxWidth    =   5680
         End
         Begin VB.Label Label7 
            BackColor       =   &H0000C000&
            Caption         =   "     Details"
            BeginProperty Font 
               Name            =   "Tahoma"
               Size            =   9.75
               Charset         =   0
               Weight          =   700
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            ForeColor       =   &H00FFFFFF&
            Height          =   255
            Left            =   30
            TabIndex        =   13
            Top             =   2250
            Width           =   7665
         End
         Begin VB.Label Label8 
            BackColor       =   &H0000C000&
            Caption         =   "     Supply Borrower Information"
            BeginProperty Font 
               Name            =   "Tahoma"
               Size            =   9.75
               Charset         =   0
               Weight          =   700
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            ForeColor       =   &H00FFFFFF&
            Height          =   255
            Left            =   30
            TabIndex        =   12
            Top             =   675
            Width           =   7665
         End
      End
      Begin MSDataGridLib.DataGrid dtgList 
         Height          =   4785
         Left            =   -74880
         TabIndex        =   10
         Top             =   420
         Width           =   7725
         _ExtentX        =   13626
         _ExtentY        =   8440
         _Version        =   393216
         AllowUpdate     =   0   'False
         AllowArrows     =   -1  'True
         Appearance      =   0
         HeadLines       =   1
         RowHeight       =   15
         TabAction       =   2
         FormatLocked    =   -1  'True
         BeginProperty HeadFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ColumnCount     =   5
         BeginProperty Column00 
            DataField       =   "cTranNo"
            Caption         =   "SIF No."
            BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
               Type            =   0
               Format          =   ""
               HaveTrueFalseNull=   0
               FirstDayOfWeek  =   0
               FirstWeekOfYear =   0
               LCID            =   1033
               SubFormatType   =   0
            EndProperty
         EndProperty
         BeginProperty Column01 
            DataField       =   "dDate"
            Caption         =   "Date"
            BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
               Type            =   1
               Format          =   "MM/dd/yyyy"
               HaveTrueFalseNull=   0
               FirstDayOfWeek  =   0
               FirstWeekOfYear =   0
               LCID            =   1033
               SubFormatType   =   3
            EndProperty
         EndProperty
         BeginProperty Column02 
            DataField       =   "DeptID"
            Caption         =   "Department"
            BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
               Type            =   0
               Format          =   "MM/dd/yyyy"
               HaveTrueFalseNull=   0
               FirstDayOfWeek  =   0
               FirstWeekOfYear =   0
               LCID            =   1033
               SubFormatType   =   0
            EndProperty
         EndProperty
         BeginProperty Column03 
            DataField       =   "cAttention"
            Caption         =   "Attention"
            BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
               Type            =   0
               Format          =   "MM/dd/yyyy"
               HaveTrueFalseNull=   0
               FirstDayOfWeek  =   0
               FirstWeekOfYear =   0
               LCID            =   1033
               SubFormatType   =   0
            EndProperty
         EndProperty
         BeginProperty Column04 
            DataField       =   "cRemarks"
            Caption         =   "Remarks"
            BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
               Type            =   0
               Format          =   "MM/dd/yyyy"
               HaveTrueFalseNull=   0
               FirstDayOfWeek  =   0
               FirstWeekOfYear =   0
               LCID            =   1033
               SubFormatType   =   3
            EndProperty
         EndProperty
         SplitCount      =   1
         BeginProperty Split0 
            AllowRowSizing  =   0   'False
            BeginProperty Column00 
               ColumnAllowSizing=   -1  'True
               Locked          =   -1  'True
               ColumnWidth     =   1124.787
            EndProperty
            BeginProperty Column01 
               Locked          =   -1  'True
               ColumnWidth     =   1124.787
            EndProperty
            BeginProperty Column02 
               Locked          =   -1  'True
               ColumnWidth     =   1214.929
            EndProperty
            BeginProperty Column03 
               Locked          =   -1  'True
               ColumnWidth     =   1649.764
            EndProperty
            BeginProperty Column04 
               Locked          =   -1  'True
               ColumnWidth     =   2069.858
            EndProperty
         EndProperty
      End
   End
   Begin MSComctlLib.StatusBar sbRS 
      Align           =   2  'Align Bottom
      Height          =   285
      Left            =   0
      TabIndex        =   11
      Top             =   5430
      Width           =   8100
      _ExtentX        =   14288
      _ExtentY        =   503
      _Version        =   393216
      BeginProperty Panels {8E3867A5-8586-11D1-B16A-00C0F0283628} 
         NumPanels       =   5
         BeginProperty Panel1 {8E3867AB-8586-11D1-B16A-00C0F0283628} 
            Object.Width           =   3528
            MinWidth        =   3528
         EndProperty
         BeginProperty Panel2 {8E3867AB-8586-11D1-B16A-00C0F0283628} 
         EndProperty
         BeginProperty Panel3 {8E3867AB-8586-11D1-B16A-00C0F0283628} 
            Alignment       =   1
            AutoSize        =   1
            Bevel           =   0
            Object.Width           =   1060
            MinWidth        =   2
         EndProperty
         BeginProperty Panel4 {8E3867AB-8586-11D1-B16A-00C0F0283628} 
            Object.Width           =   3528
            MinWidth        =   3528
         EndProperty
         BeginProperty Panel5 {8E3867AB-8586-11D1-B16A-00C0F0283628} 
            Object.Width           =   3528
            MinWidth        =   3528
         EndProperty
      EndProperty
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "Tahoma"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
   End
End
Attribute VB_Name = "frmSupplyBorrow"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'IT Group Inc. 2005.09.23

Option Explicit

'Object variables
Private oNavRec As clsNavRec
Private oFormSetup As New clsFormSetup
Private oRecordset As New clsRecordset
Private oBar As New clsToolBarMenuBit

'Recordset variables
Private WithEvents rsHeader As ADODB.Recordset
Attribute rsHeader.VB_VarHelpID = -1
Private rsDetail As ADODB.Recordset

'ADO Connection variables
Private oConnection As New clsConnection
Private connHeader As ADODB.Connection
Private connDetail As ADODB.Connection

'Form mode enumeration
Enum eSBSMode
    Normal
    AddNewEdit
    Find
End Enum
Public Mode As eSBSMode

'Other declarations
Public dtgName As String
Public sBit As String
Private vBM As Variant 'Recordset bookmark variable

Private lSystemGenerated As Boolean
Public strNo As String

'Security Acess Level variables
Public lACNew As Boolean
Public lACEdit As Boolean
Public lACDelete As Boolean
Public lACPost As Boolean
Public lACCancel As Boolean
Public lACPrint As Boolean

Private Sub cmdPickCode_Click()
    If lPickListActive Then Exit Sub
    PassFilterStringValue Trim(txtCode)
    frmITGPicker.zType = QCustomer
    frmITGPicker.Show vbModal
    txtCode = frmITGPicker.zCode
    txtCustDesc = frmITGPicker.zName
    If Trim(txtCustDesc) <> "" Then SendKeys "{Tab}"
End Sub

Private Sub dtgList_HeadClick(ByVal ColIndex As Integer)
    SortGrid dtgList, ColIndex, rsHeader
End Sub

Private Sub dtgSBS_AfterColUpdate(ByVal ColIndex As Integer)
    If Mode <> AddNewEdit Then Exit Sub
    Select Case ColIndex
        Case 0
            If GetValueFrTable("cAssetNo", "ASSET", "cAssetNo = '" & Trim(dtgSBS.Columns(0).Value) & "'") <> "" Then
                dtgSBS.Col = 3
                dtgSBS.Columns(3).Value = 0
            End If
    End Select
End Sub

Private Sub dtgSBS_ButtonClick(ByVal ColIndex As Integer)
    If Mode <> AddNewEdit Then Exit Sub
    Select Case ColIndex
        Case 0
            If lPickListActive Then Exit Sub
            PassFilterStringValue Trim(dtgSBS.Columns(0).Text)
            frmITGPicker.zType = QSupply
            'frmITGPicker.sPCCode = sDivision
            frmITGPicker.Show vbModal
            rsDetail!cItemNo = Trim(frmITGPicker.zCode) & ""
            If (Trim(frmITGPicker.zName) & "") <> "" Then
                rsDetail!cDesc = Trim(GetValueFrTable("cDesc", "SUPPLY", "cSupplyNo = '" & Trim(rsDetail!cItemNo) & "'")) & ""
                rsDetail!cUnit = Trim(GetValueFrTable("cUnit", "SUPPLY", "cSupplyNo = '" & Trim(rsDetail!cItemNo) & "'")) & ""
                dtgSBS.Col = 3
                dtgSBS.Columns(3).Value = 0
            End If
    End Select
End Sub

'Set the datagrid as active control
Private Sub dtgSBS_Click()
    If Mode = AddNewEdit Then dtgName = dtgSBS.Name
End Sub

Private Sub dtgSBS_Error(ByVal DataError As Integer, Response As Integer)
    Response = 0
End Sub

Private Sub dtgSBS_KeyDown(KeyCode As Integer, Shift As Integer)
    If Mode <> AddNewEdit Then Exit Sub
    If (Shift = vbCtrlMask And KeyCode = 45) Then
        TBNewLine
    ElseIf (Shift = vbCtrlMask And KeyCode = 46) Then
        TBDeleteLine
    ElseIf (Shift = vbCtrlMask And KeyCode = 83) Then
        TBSave
    End If
End Sub

Private Sub dtgSBS_KeyPress(KeyAscii As Integer)
    If Mode <> AddNewEdit Then Exit Sub
    If rsDetail.RecordCount = 0 Then Exit Sub

    If KeyAscii = 39 Then KeyAscii = 0 'Apostrophe {'}

    If KeyAscii = 13 Then
        Select Case dtgSBS.Col
            Case 3
                TBNewLine
                dtgSBS.LeftCol = 0
'            Case 6
'                dtgSBS_AfterColUpdate (6)
            Case Else
                SendKeys "{Tab}"
        End Select
    Else
        KeyAscii = Asc(UCase(Chr(KeyAscii))) 'All Upper Case String
    End If
End Sub

'Right click menu popup
Private Sub dtgSBS_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    If Mode <> AddNewEdit Then Exit Sub
    If Button = 2 Then
        dtgName = dtgSBS.Name
        PopupMenu ITGLedgerMain.mnuDetail
    End If
End Sub

'Set Your Object
Private Sub Form_Load()

    'MUST BE REPLACED BY PROPER ACCESS LEVEL
    'This is same as Purchase Request
    oBar.AcessBit Me, GetValueFrTable("AccessLevel", "SEC_ACCESSLEVEL", "RoleID = '" & SecUserRole & "' AND [Module] = 'PPPR'")

    Set rsHeader = New ADODB.Recordset
    Set rsDetail = New ADODB.Recordset
    Set oNavRec = New clsNavRec

    Set FrmName = Me
    oFormSetup.FormLocking True
    oFormSetup.FormSearch True
    SearchObj True
    oBar.BitEnabled Me, ITGLedgerMain.tbrMain, lACNew, , , , , , , , , True, , , True
    oBar.BitVisible ITGLedgerMain.tbrMain, True
    ITGLedgerMain.tbrMain.Buttons("btnFind").ButtonMenus("btnFindP").Enabled = True

    Mode = Find
    txtTranNo.Locked = False
End Sub

'Activate your Toolbar Mode
Private Sub Form_Activate()
    TBBitReload
End Sub

'Release your Object
Private Sub Form_Unload(Cancel As Integer)
On Error Resume Next
    If Mode = AddNewEdit Then
        MsgBox "Unable to close. You are in Add/New/Edit mode." & vbCr & _
            " Must Save or Undo", vbCritical, Me.Caption
        Cancel = True
        Exit Sub
    End If

    oBar.BitEnabled Me, ITGLedgerMain.tbrMain, , , , , , , , , , True
    oBar.BitVisible ITGLedgerMain.tbrMain
    ITGLedgerMain.tbrMain.Buttons("btnFind").ButtonMenus("btnFindP").Enabled = False

    Set oNavRec = Nothing
    Set oFormSetup = Nothing
    Set oRecordset = Nothing
    Set oBar = Nothing
    Set rsHeader = Nothing
    Set rsDetail = Nothing
    Set connHeader = Nothing
    Set connDetail = Nothing

    Set frmSupplyBorrow = Nothing

    lCloseWindow = True
End Sub

'Add new record to the recordset
Public Sub TBNew()

    oBar.BitEnabled Me, ITGLedgerMain.tbrMain, , , , True, True, , , True, True, , , , True
    txtTranNo.BackColor = &HE0FFFF
    Mode = AddNewEdit

    If rsHeader.State <> adStateOpen Then
        oConnection.OpenNewConnection connHeader
        oConnection.OpenNewConnection connDetail
        oRecordset.OpenRecordsetWithCN rsDetail, "*", "SBS_T", connDetail, "WHERE 1 = 0"
        oRecordset.OpenRecordsetWithCN rsHeader, "*", "SBS", connHeader, "WHERE 1 = 0"
        SetDataSource
        SetDataField
    Else
        vBM = rsHeader.Bookmark
    End If

    rsHeader.AddNew
    rsHeader!cCompanyID = COID
    rsHeader!dDate = Date

    Set FrmName = Me
    oFormSetup.FormLocking False
    oFormSetup.ClrRequired &HC0&
    SSTab1.Tab = 0
    txtTranNo.SetFocus

    'System generated number
    lSystemGenerated = GetValueFrTable("lBit", "SYSTEM_OPTION", "cCode = 'AUTO_NUMBER_SUP' ")
    If lSystemGenerated Then rsHeader!cTranNo = GetAutoCtrlNo(rsHeader, "AUTO_NUMBER_SUP", "SBS", "cTranNo")

End Sub

'Undo all changes to the recordset
Public Sub TBUndoAll()
On Error GoTo ErrorHandler

    Mode = Normal

    If rsHeader.Status = adRecNew Then TBUndoCurrent

    rsHeader.CancelBatch adAffectAll
    rsDetail.CancelBatch adAffectAll

    oRecordset.UnbindControls

    If rsHeader.RecordCount <> 0 Then rsHeader.Bookmark = vBM

    Set FrmName = Me
    oFormSetup.FormLocking True

    If rsHeader.RecordCount <> 0 Then
        oBar.BitEnabled Me, ITGLedgerMain.tbrMain, lACNew, lACEdit, lACDelete, , , , , , , True, True, , True
    Else
        RSZero
        Mode = Find
    End If

    sbRS.Panels(2) = ""

    SetDataSource
    SetDataField

ErrorHandler:
    If Err.Number = -2147217885 Then
        Resume Next
    ElseIf Err.Number = -2147217842 Then 'Operation was cancelled. (Error returned by ITGDateBox)
        TBUndoAll
    End If
End Sub

'Undo changes on the current record
Public Sub TBUndoCurrent()
On Error GoTo ErrorHandler

    GetChild
    If rsHeader.Status = adRecNew Then
        rsDetail.CancelBatch adAffectAll
        rsHeader.CancelUpdate
    Else
        rsHeader.CancelBatch adAffectCurrent
        rsDetail.CancelBatch adAffectAll
    End If

    If rsHeader.RecordCount = 0 Then RSZero

ErrorHandler:
    If Err.Number = -2147217885 Then
        Resume Next
    ElseIf Err.Number = -2147217842 Then 'Operation was cancelled. (Error returned by ITGDateBox)
        TBUndoCurrent
    End If
End Sub

'Save all changes
Public Sub TBSave()
Dim OKUpdate As Boolean
On Error GoTo ErrHandler

    'Audit Trail
    lBoolean = False
    If rsHeader.Status = adRecNew Then lBoolean = True

    If Not MandatoryOK Then Exit Sub

    'System generated number
    If rsHeader.Status = adRecNew Then
        If lSystemGenerated Then
            If ChkCtrlNo(rsHeader, "AUTO_NUMBER_SUP", "SBS", "cTranNo", rsHeader!cTranNo) <> rsHeader!cTranNo Then
                GetChild

                rsHeader!cTranNo = strNo

                If rsDetail.RecordCount <> 0 Then rsDetail.MoveFirst
                Do Until rsDetail.EOF
                    rsDetail!cTranNo = strNo
                    rsDetail.MoveNext
                Loop

                GetChild
            End If
        End If
    End If

    OKUpdate = False
    cn.BeginTrans
    connHeader.BeginTrans
    connDetail.BeginTrans

    rsHeader.UpdateBatch adAffectAll
    rsDetail.UpdateBatch adAffectAll

    cn.CommitTrans
    connHeader.CommitTrans
    connDetail.CommitTrans
    OKUpdate = True

    Set FrmName = Me
    oFormSetup.FormLocking True
    oBar.BitEnabled Me, ITGLedgerMain.tbrMain, lACNew, lACEdit, lACDelete, , , , , , , True, True, , True
    Mode = Normal

    'Audit trail
    UpdateLogFile "Supply Borrower", Trim(txtTranNo), IIf(lBoolean, "Inserted", "Updated")

    'update system generated number
    If lBoolean Then
        If lSystemGenerated And strNo = rsHeader!cTranNo Then UpdateControlNo strNo, rsHeader!cTranNo, "AUTO_NUMBER_SUP"
    End If

    MsgBox "Record/s successfully saved.", vbInformation, "ComUnion"
    sbRS.Panels(2) = ""

ErrHandler:
    If Err.Number = -2147217885 Then
        Resume Next
    ElseIf Err.Number = -2147217864 Then
        OKUpdate = True
        cn.RollbackTrans
        connHeader.RollbackTrans
        connDetail.RollbackTrans
        MsgBox "Record cannot be updated. Some values may have been changed by other user/s since last read." & vbCr & _
                "Records will be automatically refreshed. All changes made to the record will be gone upon refresh.", vbInformation, "ComUnion"
        vBookMark = rsHeader.Bookmark
        oRecordset.UnbindControls
        rsHeader.Requery
        rsDetail.Requery
        oBar.BitEnabled Me, ITGLedgerMain.tbrMain, lACNew, lACEdit, lACDelete, , , , , , , True, True, , True
        Mode = Normal
        If rsHeader.RecordCount <> 0 Then
            Set FrmName = Me
            oFormSetup.FormLocking True
            SetDataField
            SetDataSource
            rsHeader.Bookmark = vBookMark
        Else
            RSZero
        End If
    End If
    If Not OKUpdate Then
        MsgBox "Transaction update failed.", vbInformation, "ComUnion"
        cn.RollbackTrans
        connHeader.RollbackTrans
        connDetail.RollbackTrans
        ErrorLog Err.Number, Err.Description, Me.Name 'Error log
    End If
End Sub

'Sets the form & recorset to add/edit mode
Public Sub TBEdit()
    Mode = AddNewEdit
    oBar.BitEnabled Me, ITGLedgerMain.tbrMain, , , , True, True, , , True, True, , , , True
    Set FrmName = Me
    oFormSetup.FormLocking False
    oFormSetup.ClrRequired &HC0&
    txtTranNo.Locked = True
    SSTab1.Tab = 0
    dtbDate.SetFocus
    vBM = rsHeader.Bookmark
End Sub

'Delete record
Public Sub TBDelete()
On Error GoTo ErrorHandler

    sID = Trim(txtTranNo)

    If rsHeader.RecordCount = 0 Then Exit Sub

    If MsgBox("Are you sure you want to delete this record?", vbQuestion + vbYesNo, "ComUnion") = vbNo Then Exit Sub

    GetChild
    If rsDetail.RecordCount <> 0 Then
        rsDetail.MoveFirst
        Do Until rsDetail.RecordCount = 0
            rsDetail.Delete adAffectCurrent
            If rsDetail.RecordCount <> 0 Then rsDetail.MoveFirst
        Loop
    End If

    'Audit trail
    UpdateLogFile "Supply Borrower", Trim(txtTranNo), "Deleted"

    rsHeader.Delete adAffectCurrent

    rsDetail.UpdateBatch adAffectAll
    rsHeader.UpdateBatch adAffectAll

    TBPrevRec

    Mode = Normal

    If rsHeader.RecordCount = 0 Then
        RSZero
    End If

ErrorHandler:
    If Err.Number = -2147217885 Then
        Resume Next
    ElseIf Err.Number = -2147217864 Then
        cn.Execute "DELETE SBS_T WHERE cTranNo = '" & sID & "' AND cCompanyID = '" & COID & "'"
        cn.Execute "DELETE SBS WHERE cTranNo = '" & sID & "' AND cCompanyID = '" & COID & "'"
        Resume Next
    End If
End Sub

'Search using the frmITGSearch
Public Sub TBFind()
    Mode = Normal
    txtTranNo.Locked = True
    frmITGSearch.Show 'vbModal
End Sub

'Search using the recordset primary key
Public Sub TBFindPrimary()
Dim sTemp As String
If Mode = Find Then
    FormWaitShow "Loading data . . ."

    oConnection.OpenNewConnection connHeader
    oConnection.OpenNewConnection connDetail

    Set rsHeader = Nothing
    Set rsDetail = Nothing
    Set rsHeader = New ADODB.Recordset
    Set rsDetail = New ADODB.Recordset

    sTemp = Trim$(GetSearchString)
    If sTemp = "ERROR" Then
        MsgBox "Only Allows A - Z, 0 - 9, '.', ',' and %(wildcard)", vbExclamation, ""
        oBar.BitEnabled Me, ITGLedgerMain.tbrMain, lACNew, , , , , , , , , True, , , True
        txtTranNo.Locked = False
        txtTranNo.SetFocus
        Exit Sub
    End If

    oRecordset.OpenRecordsetWithCN rsHeader, "*", "SBS", connHeader, IIf(sTemp = "", "", " WHERE " & sTemp)
    oRecordset.OpenRecordsetWithCN rsDetail, "*", "SBS_T", connDetail

    Set FrmName = Me
    oFormSetup.FormLocking True

     If rsHeader.RecordCount = 0 Then
        Unload frmWait
        MsgBox "No matching record/s found.", vbInformation, "ComUnion Search"
        RSZero
        oFormSetup.FormSearch True
        SearchObj True
        Mode = Find
        Exit Sub
    End If
    SetDataSource
    SetDataField
    txtTranNo.BackColor = &HE0FFFF
    Mode = Normal
    oBar.BitEnabled Me, ITGLedgerMain.tbrMain, lACNew, lACEdit, lACDelete, , , , , , , True, True, , True

    Unload frmWait
Else
    RSZero
    oFormSetup.FormSearch True
    SearchObj True
    Mode = Find
End If

End Sub

'Reload menu buttons (do not delete this sub)
Public Sub TBBitReload()
    oBar.BitVisible ITGLedgerMain.tbrMain, True
    ITGLedgerMain.tbrMain.Buttons("btnFind").ButtonMenus("btnFindP").Enabled = True
    oBar.BitReload Me, ITGLedgerMain.tbrMain, sBit
    Set FrmName = Me
    dtgName = dtgSBS.Name
End Sub

'Close active window
Public Sub TBCloseWindow()
    Unload Me
End Sub

'Move first
Public Sub TBFirstRec()
    If rsHeader.State <> adStateOpen Then Exit Sub
    oNavRec.MoveFirst rsHeader
End Sub

'Move previuos
Public Sub TBPrevRec()
    If rsHeader.State <> adStateOpen Then Exit Sub
    oNavRec.MovePrevious rsHeader
End Sub

'Move next
Public Sub TBNextRec()
    If rsHeader.State <> adStateOpen Then Exit Sub
    oNavRec.MoveNext rsHeader
End Sub

'Move last
Public Sub TBLastRec()
    If rsHeader.State <> adStateOpen Then Exit Sub
    oNavRec.MoveLast rsHeader
End Sub

'Add new line to the detail recordset
Public Sub TBNewLine()

    If rsHeader!cTranNo = "" Then Exit Sub
    
    If dtgName = "dtgSBS" Then
        rsDetail.AddNew
        rsDetail!cCompanyID = COID
        rsDetail!cTranNo = Trim(rsHeader!cTranNo)
        GetChild
        If rsDetail.RecordCount <> 0 Then rsDetail.MoveLast
        dtgSBS.Col = 0
        dtgSBS.Columns(0).Value = ""
        dtgSBS.SetFocus
    End If
    
    oBar.BitEnabled Me, ITGLedgerMain.tbrMain, , , , True, True, , , True, True, , , , True

End Sub

'Delete line in the detail recordset
Public Sub TBDeleteLine()
On Error GoTo ErrorHandler

    If dtgName = dtgSBS.Name Then
        If rsDetail.RecordCount = 0 Then Exit Sub
        vBookMark = dtgSBS.Bookmark
        GetChild
        dtgSBS.Bookmark = vBookMark
        rsDetail.Delete adAffectCurrent
    End If
    GetChild

    oBar.BitEnabled Me, ITGLedgerMain.tbrMain, , , , True, True, , , True, True, , , , True

ErrorHandler:
    If Err.Number = -2147217885 Then
        Resume Next
    End If

End Sub

'Undo All
Public Sub TBUndoLineAll()
On Error GoTo ErrorHandler

    MsgBox "Unavailable on " & Me.Name

ErrorHandler:
    If Err.Number = -2147217885 Then
        Resume Next
    End If

End Sub

'Undo current line
Public Sub TBUndoLineCurrent()
    MsgBox "Unavailable on " & Me.Name
End Sub

'Post current record
Public Sub TBPostRecord()
    MsgBox "Unavailable on " & Me.Name
End Sub

''Cancel current record
'Public Sub TBCancelRecord()
'On Error GoTo ErrorHandler
'
'    If rsHeader.RecordCount = 0 Then Exit Sub
'
'    If rsHeader!lCancelled = True Then
'        MsgBox "Transaction was already cancelled.", vbExclamation, "ComUnion"
'        Exit Sub
'    End If
'
'    If MsgBox("Are you sure you want to cancel this record?", vbQuestion + vbYesNo, "ComUnion") = vbNo Then Exit Sub
'
'    'CANCELLATION CONSTRAINT
'    'If Not AllowDelete("cancel") Then Exit Sub
'
'    'Audit trail
'    UpdateLogFile "Supply Issuance", Trim(txtTranNo), "Cancelled"
'
'    cn.Execute ("UPDATE SBS SET lCancelled = 1 WHERE cTranNo = '" & Trim(txtTranNo) & "' AND cCompanyID = '" & COID & "'")
'
'    sbRS.Panels(5) = "CANCELLED"
'    Mode = Normal
'
'    rsHeader!lCancelled = True
'    rsHeader.UpdateBatch adAffectAll
'
'ErrorHandler:
'    If Err.Number = -2147217885 Then
'        Resume Next
'    End If
'
'End Sub

'Print
Public Sub TBPrintRecord()
    MsgBox "Unavailable on " & Me.Name
End Sub

'Sets the data source of the controls
Sub SetDataSource()
    Set FrmName = Me
    oRecordset.BindControls rsHeader
    Set dtgList.DataSource = rsHeader
    Set dtgSBS.DataSource = rsDetail
End Sub

'Sets the data field for every bounded controls
Sub SetDataField()
    With rsHeader
        txtTranNo.DataField = !cTranNo
        dtbDate.DataField = !dDate
        txtCode.DataField = !cCode
        txtAttention.DataField = !cAttention
        txtRemarks.DataField = !cRemarks
    End With
End Sub

Private Sub rsHeader_MoveComplete(ByVal adReason As ADODB.EventReasonEnum, ByVal pError As ADODB.Error, adStatus As ADODB.EventStatusEnum, ByVal pRecordset As ADODB.Recordset)
On Error GoTo ErrorHandler

    If Not (rsHeader.EOF) Or Not (rsHeader.BOF) Then
        'Status bar setup
        sbRS.Panels(1) = "Record: " & IIf((rsHeader.AbsolutePosition = -2), "0", rsHeader.AbsolutePosition) & "/" & rsHeader.RecordCount

        If rsHeader.Status <> adRecNew Then
            txtTranNo.Locked = True
        Else
            txtTranNo.Locked = False
        End If

        If Mode = AddNewEdit Then
            Select Case rsHeader.Status
                Case adRecNew
                    sbRS.Panels(2) = "New"
                Case adRecModified
                    sbRS.Panels(2) = "Modified"
                Case Else
                    sbRS.Panels(2) = ""
            End Select
        Else
            sbRS.Panels(2) = ""
        End If

        GetChild

        If rsHeader!lCancelled = True Then
            sbRS.Panels(5) = "CANCELLED"
        Else
            sbRS.Panels(5) = ""
        End If

    Else
        sbRS.Panels(1) = "Record: 0/0"
        sbRS.Panels(2) = ""
        txtTranNo.Locked = False
    End If

    If Mode = AddNewEdit Then
        dtgSBS.Refresh
    End If

ErrorHandler:
    'Err.Number -2147217885
    'Description - Row handle referred to a deleted row or a row marked for deletion.
    If Err.Number = -2147217885 Then
        Resume Next
    End If

End Sub

Private Sub Timer1_Timer()
    If Mode = AddNewEdit Then
        SSTab1.TabEnabled(1) = False
    Else
        SSTab1.TabEnabled(1) = True
    End If
End Sub

Private Sub txtCode_Change()
    txtCustDesc = ""
    txtCustDesc = GetValueFrTable("cName", "CLIENT_CUSTOMER", "cCode = '" & Trim(txtCode) & "'", True)
End Sub

Private Sub txtRemarks_LostFocus()
    If Mode <> AddNewEdit Then Exit Sub
    If rsDetail.RecordCount = 0 Then TBNewLine
End Sub

Private Sub txtTranNo_LostFocus()
    'Does Code Already Exist
    If Mode = AddNewEdit Then
        If Trim(txtTranNo) = "" Then
            MsgBox "Empty primary input.", vbInformation, "ComUnion"
            txtTranNo.SetFocus
        Else
            If rsHeader.Status <> adRecNew Then Exit Sub
            txtTranNo = Trim(txtTranNo)
            If IDExisting(rsHeader, "cTranNo", "SBS", Trim(rsHeader!cTranNo)) Then
                MsgBox "SBS No. already exist.", vbInformation, "ComUnion"
                txtTranNo.SetFocus
            End If
        End If
    End If
End Sub

'Check if all mandatory fields are complete
Function MandatoryOK() As Boolean

    MandatoryOK = True

    If Trim(txtTranNo) = "" Then
        MandatoryOK = False
        MsgBox "Field 'SIF Number' is mandatory. Null value is not allowed.", vbInformation, "ComUnion"
        txtTranNo.SetFocus
        Exit Function
    End If

    If rsHeader.Status = adRecNew And lSystemGenerated = False Then
        If IDExisting(rsHeader, "cTranNo", "SBS", Trim(rsHeader!cTranNo)) Then
            MandatoryOK = False
            MsgBox "SIF No. already exist.", vbInformation, "ComUnion"
            txtTranNo.SetFocus
            Exit Function
        End If
    End If

    'Required fields
    If Trim(dtbDate.Text) = "__/__/____" Then
        MandatoryOK = False
        MsgBox "Field 'Transaction Date' is mandatory. Null value is not allowed.", vbInformation, "ComUnion"
        dtbDate.SetFocus
        Exit Function
    End If

    GetChild

    'Transaction without details
    If rsDetail.RecordCount = 0 Then
        MandatoryOK = False
        MsgBox "Cannot save transaction without details.", vbInformation, "ComUnion"
        dtgSBS.SetFocus
        Exit Function
    End If

    If rsDetail.RecordCount <> 0 Then rsDetail.MoveFirst
    Do Until rsDetail.EOF
        If rsDetail.Status = (adRecNew) Or rsDetail.Status = (adRecModified) Then
            If IsNull(rsDetail!cItemNo) Then
                rsDetail.Delete
            ElseIf Trim(rsDetail!cItemNo) = "" Then
                rsDetail.Delete
            Else
                rsDetail.MoveNext
            End If
        Else
            rsDetail.MoveNext
        End If
    Loop

    GetChild

    If rsDetail.RecordCount < 1 Then
        MsgBox "Cannot save transaction without details.", vbExclamation, "ComUnion"
        MandatoryOK = False
        Exit Function
    End If

End Function

'Filter detail recordset to header's primary
Private Sub GetChild()
    rsDetail.Filter = "cTranNo = '" & Trim(rsHeader!cTranNo) & "'"
End Sub

Private Function GetSearchString() As String
On Error GoTo ErrorHandler
Dim sWhere As String

    GetSearchString = True

    If Trim$(txtTranNo.Text) <> "" Then
        sWhere = sWhere & IIf(Trim$(sWhere) = "", "", " AND ") & " cTranNo LIKE '" & Trim$(txtTranNo.Text) & "%'"
    End If

    If Trim$(dtbDate.Text) <> "__/__/____" Then
        sWhere = sWhere & IIf(Trim$(sWhere) = "", "", " AND ") & " dDate = '" & Trim$(dtbDate.Text) & "'"
    End If

    If Trim$(txtCode.Text) <> "" Then
        sWhere = sWhere & IIf(Trim$(sWhere) = "", "", " AND ") & " cCode LIKE '" & Trim$(txtCode.Text) & "%'"
    End If

    GetSearchString = Trim$(sWhere)

    Exit Function
ErrorHandler:
    GetSearchString = "ERROR"
End Function

'Sets the form if record number is zero
Private Sub RSZero()
    sbRS.Panels(1) = "Record: 0/0"
    sbRS.Panels(2) = ""
    sbRS.Panels(4) = ""
    sbRS.Panels(5) = ""

    Set dtgSBS.DataSource = Nothing
    dtgSBS.Refresh

    Set FrmName = Me
    oRecordset.UnbindControls
    oFormSetup.TextClearing
    oFormSetup.FormLocking True

    If rsHeader.State = adStateOpen Then rsHeader.Close
    If rsDetail.State = adStateOpen Then rsDetail.Close

    oBar.BitEnabled Me, ITGLedgerMain.tbrMain, lACNew, , , , , , , , , True, , , True

    txtTranNo.Locked = False
    txtTranNo.SetFocus

    Mode = Find

End Sub

Sub SearchObj(lEnable As Boolean)
    dtbDate.Enabled = lEnable
    cmdPickCode.Enabled = lEnable
End Sub

''Load picklist
'Private Sub LoadPickList()
'
'    If Mode <> AddNewEdit Then Exit Sub
'
'    If Trim(dtbDate.Text) = "__/__/____" Then
'        MsgBox "Please input transaction date.", vbInformation, "ComUnion"
'        dtbDate.SetFocus
'        Exit Sub
'    ElseIf Trim(txtCustDesc) = "" Then
'        MsgBox "Existing Department Requiered.", vbInformation, "ComUnion"
'        txtCode.SetFocus
'        Exit Sub
'    End If
'
'    frmARDRList.mDRType = RequestForIssuance
'    frmARDRList.Show vbModal
'
'End Sub
'
''Form list to grid
'Public Sub AddDetailsFromList()
'
'    GetChild
'
'    With frmARDRList.lvwList
'        For i = 1 To .ListItems.Count
'            If .ListItems(i).Checked = True Then
'                rsDetail.AddNew
'                rsDetail!cCompanyID = COID
'                rsDetail!cTranNo = Trim(rsHeader!cTranNo)
'                rsDetail!cRefNo = Trim(frmARDRList.mRefPK)
'                rsDetail!cItemNo = Trim(.ListItems(i).Text)
'                rsDetail!cDesc = Trim(.ListItems(i).SubItems(1))
'                rsDetail!cUnit = Trim(.ListItems(i).SubItems(3))
'                rsDetail!nQty = CDbl(.ListItems(i).SubItems(4))
'                rsDetail!nRefIdentity = CDbl(.ListItems(i).SubItems(7))
'                rsDetail!cItemType = GetValueFrTable("cItemType", "REQUISITIONSLIP_T", "cTranNo = '" & rsDetail!cRefNo & "' AND nIdentity = " & rsDetail!nRefIdentity & " ")
'                rsDetail!nPrice = 0
'                rsDetail!nAmount = 0
'             End If
'        Next i
'    End With
'
'    GetChild
'
'End Sub
'
''Computes total amount per detail line
'Private Sub ComputeAmount()
'Dim nAmount As Double
'    If Mode <> AddNewEdit Then Exit Sub
'    With dtgSBS
'        nAmount = IIf(IsNull(.Columns(6).Value), 0, .Columns(6).Value) * _
'                    IIf(IsNull(.Columns(5).Value), 0, .Columns(5).Value)
'        .Columns(7).Text = Format(nAmount, "###,##0.#0")
'    End With
'End Sub

Public Sub ShowForm(sTranNo As String)
    If Mode = Find Then

        oConnection.OpenNewConnection connHeader
        oConnection.OpenNewConnection connDetail

        Set rsHeader = Nothing
        Set rsDetail = Nothing
        Set rsHeader = New ADODB.Recordset
        Set rsDetail = New ADODB.Recordset

        oRecordset.OpenRecordsetWithCN rsDetail, "*", "SBS_T", connDetail, "WHERE cTranNo = '" & Trim(sTranNo) & "'"
        oRecordset.OpenRecordsetWithCN rsHeader, "*", "SBS", connHeader, "WHERE cTranNo = '" & Trim(sTranNo) & "'"

        Set FrmName = Me
        oFormSetup.FormLocking True

        If rsHeader.RecordCount = 0 Then
            Unload frmWait
            MsgBox "No matching record/s found.", vbInformation, "ComUnion Search"
            RSZero
            oFormSetup.FormSearch True
            SearchObj True
            Mode = Find
            Exit Sub
        End If
            SetDataSource
            SetDataField
            txtTranNo.BackColor = &HE0FFFF
            Mode = Normal
            oBar.BitEnabled Me, ITGLedgerMain.tbrMain, lACNew, lACEdit, lACDelete, , , , , , , True, True, , True, True

    End If
End Sub

'Sub UpdateRSIssuance()
'End Sub
